package Offer.offer2019;

/**
 * 二进制中1的个数
 *
 * @author: leiwenkang02@meituan.com
 * @date: 2019/4/22
 * @time: 20:17
 */
public class Offer10 {

    public int getNumberOfOne(int num) {
        int count = 0;
        while (num != 0) {
            num &= (num - 1);
            count++;
        }
        return count;
    }
}
